package routers

import (
	"gPublic/Controllers"

	"github.com/gin-gonic/gin"
)

func AppRoutes(r *gin.Engine) {
	r.Use(func(c *gin.Context) {
		c.Writer.Header().Set("Access-Control-Allow-Origin", "*")
		c.Writer.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
		c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
		if c.Request.Method == "OPTIONS" {
			c.AbortWithStatus(200)
			return
		}
		c.Next()
	})

	r.GET("/tree", Controllers.GetCategoryList)
	r.POST("/resumeAna", Controllers.ResumeAnalysis)

	MysqlRouterGroup := r.Group("/user/dir/")
	{
		MysqlRouterGroup.GET("list", Controllers.UsersDirList)
		MysqlRouterGroup.GET("size", Controllers.UsersDirSize)
		MysqlRouterGroup.GET("del", Controllers.UsersDirDel)
	}

}
